﻿using System;
using System.Windows.Controls;
using Ninject.Modules;

using SSTU.Contract.Facade;
using SSTU.Contract.Interaction;
using SSTU.Facade;
using SSTU.Interaction;
using SSTU.ViewModel;

namespace SSTU.Management.Module
{
	/// <summary>
	/// Main configuration module for application.
	/// </summary>
	public class SstuModule : NinjectModule
	{
		private readonly Frame _frame;

		/// <summary>
		/// Initializes a new instance of the <see cref="SstuModule"/> class.
		/// </summary>
		/// <param name="frame">The root application frame.</param>
		public SstuModule(Frame frame)
		{
			_frame = frame;
		}

		/// <summary>
		/// Loads and configures this module.
		/// </summary>
		public override void Load()
		{
			var structureFacade = new StructureFacade();
			var cacheStructureFacade = new CacheStructureFacade(structureFacade);
			var timeTableFacade = new TimeTableFacade();
			var cacheTimeTableFacade = new CacheTimeTableFacade(timeTableFacade);
			var navigationInteraction = new NavigationInteraction(_frame);
			Kernel.Bind<IStructureFacade>().ToConstant(cacheStructureFacade);
			Kernel.Bind<ITimeTableFacade>().ToConstant(cacheTimeTableFacade);
			Kernel.Bind<INavigationInteraction>().ToConstant(navigationInteraction);
			Kernel.Bind<TimeTableMenuViewModel>().To<TimeTableMenuViewModel>();
			Kernel.Bind<FacultyMenuViewModel>().To<FacultyMenuViewModel>();
		}
	}
}
